Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming


Raising and handling error conditions

Methods do not support the RETURN statement with the ERROR option. The compiler generates an error if it encounters this statement in a constructor, destructor, or method in a class file. In addition, the compiler generates an error if the RETURN ERROR option of the ON ERROR phrase is used within a class.

In a class or method, you must provide an application-defined mechanism for returning status information to callers. There are several approaches that you might use to have an invoked method inform its caller that it has encountered an error. One mechanism for returning this status information is for the invoked method to set a status output parameter. Alternatively, the invoked method can set a public status data member. In either case, the caller of the method needs to evaluate this status information in order to detect if the method has executed successfully. However, statements within a method, constructor, or destructor can still fail and raise an error condition, so you must still code for them and handle these conditions appropriately.

Comparison with procedure-based programming

The 4GL supports a mechanism for procedures to raise an error condition in the caller. There is no parallel mechanism for a user-defined function or a class-based method. Procedures can use the RETURN ERROR statement to cause an ERROR condition to be raised in the calling block. This causes the ERROR condition to be raised for the RUN statement that invoked the procedure. An application can use the ERROR option of the RETURN statement only in a procedure or a database trigger block. An application cannot use the ERROR condition from a user-defined function or method.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095